<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf" %>
<script type="text/javascript" src="${ctx}/js/finance/purchasingmanagement/customerCutMaterial_edit.js">
</script>
<style type="text/css">
.col-sm-3 {
	width: 15%;
	float: left;
}

.col-sm-9 {
	width: 85%;
	float: left;
}
label[class^="btn btn-default"]{
	margin-top: -4px;
}
</style>
</head>
<body>
	<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
	<form id="form" name="form" class="form-horizontal" method="post"
		action="${ctx}/finance/customerCutMaterial_editEntity.shtml">
		<input type="hidden" class="form-control checkacc"
			name="customerCutMaterialFormMap.id" id="id" value="${customerCutMaterialFormMap.id }">
		<input type="hidden" class="form-control checkacc" 
			name="pcontractTrackingFormMap.state" id="id">
		<section class="panel panel-default">
		<div class="panel-body">
		
		
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">客户</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkabh" value="${customerCutMaterialFormMap.client }"
						placeholder="请输入客户" name="customerCutMaterialFormMap.client" id="nc_code_group_no">
				</div>
			</div>
		
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">是否外协</label>
				<div class="col-sm-9">
					<select class="form-control" name="customerCutMaterialFormMap.whetherOutsourcing">
						<option <c:if test="${customerCutMaterialFormMap.whetherOutsourcing==1 }">selected</c:if> value="1">是</option>
						<option <c:if test="${customerCutMaterialFormMap.whetherOutsourcing==0 }">selected</c:if> value="0">否</option>
					</select>
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">申请单号</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkabh" value="${customerCutMaterialFormMap.requestCode }"
						placeholder="请输入申请单号" name="customerCutMaterialFormMap.requestCode" id="nc_code_group_no">
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">申请时间</label>
				<div class="col-sm-9">
					<input style="width: 50%;" type="datetime-local" class="form-control" value="${customerCutMaterialFormMap.timeOfApplication }"
					 name="customerCutMaterialFormMap.timeOfApplication" placeholder="请选择计划备模时间">
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">申请数</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName" value="${customerCutMaterialFormMap.applicationNumber }"
						placeholder="请输入申请数" name="customerCutMaterialFormMap.applicationNumber" id="nc_code_group_desc">
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">回料数</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName" value="${customerCutMaterialFormMap.feedBackNumber }"
						placeholder="请输入回料数" name="customerCutMaterialFormMap.feedBackNumber" id="nc_code_group_desc">
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">回发票</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName" value="${customerCutMaterialFormMap.backInvoice }"
						placeholder="请输入发票" name="customerCutMaterialFormMap.backInvoice" id="nc_code_group_desc">
				</div>
			</div>
		
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">供应商</label>
				<div class="col-sm-9">
					<select class="form-control" name="customerCutMaterialFormMap.materialBrandId"> 
						<c:forEach var="b" items="${brandFormMap }">
							<option <c:if test="${b.id==customerCutMaterialFormMap.materialBrandId}">selected</c:if> value="${b.id }">${b.name }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">物料编码</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName" value="${customerCutMaterialFormMap.materialCode }"
						placeholder="请输入物料编码" name="customerCutMaterialFormMap.materialCode" id="nc_code_group_desc">
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">含税单价</label>
				<div class="col-sm-9">
					<input type="text" class="form-control checkName" value="${customerCutMaterialFormMap.unitPrice }"
						placeholder="请输入含税单价" name="customerCutMaterialFormMap.unitPrice" id="nc_code_group_desc">
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">进仓时间</label>
				<div class="col-sm-9">
					<input style="width: 50%;" type="datetime-local" class="form-control" value="${customerCutMaterialFormMap.warehousingTime }"
					 name="customerCutMaterialFormMap.warehousingTime" placeholder="请选择计划备模时间">
				</div>
			</div>
			
			
			
			<!-- 子项 -->
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="panel panel-default">
				<div class="panel-body">
					<table class="table table-bordered">
						<thead>
							<tr>
								<th style="text-align: center;width:176px;">申请单号</th>
								<th style="text-align: center;width:135px;">申请时间</th>
								<th style="text-align: center;width:136px;">申请数</th>
								<th style="text-align: center;width:136px;">回料数</th>
								<th style="text-align: center;width:136px;">用料数</th>
								<th style="text-align: center;width:136px;">剩余数</th>
								<th style="text-align: center;"><input type="button"
									class="btn btn-primary" onclick="insert_row(this)" value="增加"></th>
								<th style="text-align: center;"><input type="button"
									class="btn btn-danger"  readonly="readonly" value="操作"></th>
							</tr>
						</thead>
						<tbody id="tbl">
							
							 <c:forEach var="c" items="${customerCutMaterialDetailFormMap }" varStatus="status">
									<tr>
									<input type="text" class="form-control page${status.index+1 }" name="aaa" value="${c.id }">
										<td>
										
											<div class="input-group">
												<input type="hidden" class="form-control" readonly="readonly"
													name="standardId_1"  >
													
												<input type="text" class="form-control" readonly="readonly" name="item_no_1" value="${customerCutMaterialFormMap.requestCode }">
											</div>
										</td>
									<td>
										<div class="input-group">
											<input style="width: 100%;" type="datetime-local" class="form-control" readonly="readonly"
					 						name="item_time" value="${customerCutMaterialFormMap.timeOfApplication }"  placeholder="">
										</div>
									</td>
									<td>
										<div class="input-group">
											<input type="text" class="form-control" readonly="readonly" value="${customerCutMaterialFormMap.applicationNumber }"
												name="item_balance_up_1" >
										</div>
									</td>
									<td>
										<div class="input-group">
											<input type="text" class="form-control" id="handleTime" placeholder=""  readonly="readonly"
											value="${customerCutMaterialFormMap.feedBackNumber }"
												name="item_balance_down_1" >
										</div>
									</td>
									<td>
										<div class="input-group">
											<input type="text" class="form-control" value="${c.materialsFor }"
												name="item_balance_sit_1" >
										</div>
									</td>
									<td>
										<div class="input-group">
											<input type="text" class="form-control" value="${c.residueNumber }"
												name="item_balance_num_1" >
										</div>
									</td>
									<td><input type="button" class="btn btn-primary"
										onclick="insert_row(this)" value="增加"></td>
									<td><input type="button" class="btn btn-danger" id="page${status.index+1 }" name="pageNo"
										onclick="deleteRow(this)" value="删除"></td>
								</tr>
								
								</c:forEach> 
							
						</tbody>
					</table>
				</div>
			</div>
			</div>
			
			
		<footer class="panel-footer text-right bg-light lter">
			<button type="submit" class="btn btn-success btn-s-xs">提交</button>
		</footer> 
		</section>
	</form> 
	
	
	
	<script type="text/javascript">
		var i = 0
		function insert_row(obj) {
			i++;
			R = tbl.insertRow(tbl.rows.length);
			C = R.insertCell(0);
			C.innerHTML = '<div class="input-group"><input type="text"  class="form-control" readonly="readonly" value="${customerCutMaterialFormMap.requestCode }" name="item_no_1" id="item_no_1_"></div>';
			C = R.insertCell(1);
			C.innerHTML = '<div class="input-group"><input style="width: 100%;" type="datetime-local" readonly="readonly" value="${customerCutMaterialFormMap.timeOfApplication }" name="item_time" id="item_time" class="form-control"></div>';
			C = R.insertCell(2);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control" readonly="readonly" value="${customerCutMaterialFormMap.applicationNumber }" name="item_balance_up_1" id="item_balance_up_1"></div>'; 
			C = R.insertCell(3);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control" readonly="readonly" value="${customerCutMaterialFormMap.feedBackNumber }" name="item_balance_down_1" id="item_balance_down_1"></div>';
			C = R.insertCell(4);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control" name="item_balance_sit_1" id="item_balance_sit_1"></div>';
			C = R.insertCell(5);
			C.innerHTML = '<div class="input-group"><input type="text" class="form-control" name="item_balance_num_1" id="item_balance_num_1"></div>';
			C = R.insertCell(6);
			C.innerHTML = '<input type="button" class="btn btn-primary" onclick ="insert_row(this)" value = "增加">';
			C = R.insertCell(7);
			C.innerHTML = '<input type="button" class="btn btn-danger" onclick ="deleteRow(this)" value ="删除">';
		}
		function deleteRow(obj) {
			
				$("input[name=pageNo]").each(function(){
						layer.confirm('是否删除？', function(index) {
							var oid = $(obj).attr("id");
							var cid=$("."+oid).val();
							//alert($("."+oid).val());
							var url = rootPath + '/finance/customerCutMaterialDetail_deleteEntity.shtml?cid='+cid;
							var s = CommnUtil.ajax(url, {
								
							}, "json");
							if (s == "success") {
								
								var i = obj.parentNode.parentNode.rowIndex;
								if (i >= 0) {
									tbl.deleteRow(i-1);
								}
								
								layer.msg('删除成功');
								//grid.loadData();
							} else {
								layer.msg('删除失败');
							}
							
						})
					
					
					
				});
					
					
					
				
				
				
			
			
			
			
		}
	</script>
	
	
</body>
</html>